import os
import platform

TYPE_DIR = 0  # 创建目录
TYPE_FILE = 1  # 创建文件
default = r'C:\Users\da\Desktop'  # 桌面路径


def createPath(path, type=0):
    if type == 0:
        if os.path.exists(path) is False:
            os.mkdir(path)

    if type == 1:
        if os.path.exists(path) is False:
            os.mkfifo(path)
    return path


def createContinDir(start, end, path=default):
    """
    创建连续的文件夹
    """
    if int(end) <= int(start):
        return False

    newDir = path + r'\dir'
    if os.path.exists(newDir) is False:
        os.mkdir(newDir)

    for index in range(int(start), int(end) + 1):
        dirPath = newDir + '\\' + str(index)
        if os.path.exists(dirPath) is False:
            os.mkdir(dirPath)
    return newDir


def getcurrentpath():
    '***获取当前目录***'
    return os.getcwd()


def getSyspath():
    brand = platform.platform()
    if "mac" in brand:
        return ".."
    elif "Windows" in brand:
        return "."
    else:
        return ""


def getlasepath():
    '***获取上级目录***'
    return os.path.abspath(os.path.dirname(os.getcwd()))


def getupath():
    '***获取上上级目录***'
    return os.path.abspath(os.path.join(os.getcwd(), "../.."))


def cut(obj, sec):
    '''
    字符串按定长切割
    :param obj:
    :param sec:
    :return:
    '''
    return [obj[i:i + sec] for i in range(0, len(obj), sec)]
